home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / bsd / sparc / varargs.h < prev    next >
C/C++ Source or Header  |  1994-09-14  |  3KB  |  73 lines

  1. /* varargs.h -  SPARC version
  2.                 this version uses the 'new' gcc varargs convention */
  3. /* other than the details of what gets defined when, etc., varargs.h
  4.  * & stdarg.h are identical.
  5.  */
  6.  
  7.  
  8. #ifndef _BSD_SPARC_VARARGS_H_
  9. #define _BSD_SPARC_VARARGS_H_
  10.  
  11. #define NEW_VARARGS
  12.  
  13. /* Indicate that this program uses <varargs.h>. */
  14. #define    __VARARGS__
  15.  
  16. #ifdef __STRICT_ANSI__
  17. #error <varargs.h> should not be included in an ANSI C program.
  18. #endif /* __STRICT_ANSI__ */
  19.  
  20. /* If ansi/stdarg.h was included, this overrides */
  21. #undef va_start
  22. #undef va_end
  23. #undef va_arg
  24.  
  25. /* Get the definition of `va_list'. */
  26. #define _DEFINE_VA_LIST
  27. #include <ansi/sparc/stdtypes.h>
  28.  
  29. #define va_alist    __builtin_va_alist
  30. #define va_dcl        int __builtin_va_alist;
  31.  
  32.  
  33. #ifdef NEW_VARARGS
  34. #define va_start(AP) ((AP) = ((char *) __builtin_saveregs()))
  35. #else
  36. #define va_start(AP) \
  37.   (__builtin_saveregs(), (AP) = ((char *) &__builtin_va_list)))
  38. #endif
  39.  
  40. void va_end (va_list list);           /* Defined in libgcc.a */
  41. #define va_end(pvar)
  42.  
  43. #define __va_rounded_size(TYPE)  \
  44.   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
  45.  
  46. /* RECORD_TYPE args passed using the C calling convention are
  47.    passed by invisible reference.  ??? RECORD_TYPE args passed
  48.    in the stack are made to be word-aligned; for an aggregate that is
  49.    not word-aligned, we advance the pointer to the first non-reg slot.  */
  50. /* We don't declare the union member `d' to have type TYPE
  51.    because that would lose in C++ if TYPE has a constructor.  */
  52. /* We cast to void * and then to TYPE * because this avoids
  53.    a warning about increasing the alignment requirement.
  54.    The casts to char * avoid warnings about invalid pointer arithmetic.  */
  55. #define va_arg(pvar,TYPE)                                       \
  56. __extension__                                                   \
  57. ({ TYPE __va_temp;                                              \
  58.    ((__builtin_classify_type (__va_temp) >= 12)                 \
  59.     ? ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE *),    \
  60.        **(TYPE **) (void *) ((char *)(pvar) - __va_rounded_size (TYPE *))) \
  61.     : __va_rounded_size (TYPE) == 8                             \
  62.     ? ({ union {char __d[sizeof (TYPE)]; int __i[2];} __u;      \
  63.          __u.__i[0] = ((int *) (void *) (pvar))[0];             \
  64.          __u.__i[1] = ((int *) (void *) (pvar))[1];             \
  65.          (pvar) = (char *)(pvar) + 8;                           \
  66.          *(TYPE *) (void *) __u.__d; })                         \
  67.     : ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE),      \
  68.        *((TYPE *) (void *) ((char *)(pvar) - __va_rounded_size (TYPE)))));})
  69.  
  70.  
  71.  
  72. #endif    /* _BSD_SPARC_VARARGS_H_ */
  73.